﻿/*
    CMS分页按钮 弹出框
*/

CKEDITOR.dialog.add('cmspager', function (editor) {
    var CMSPageCount = 1;
    return {
        title: "YorkCMS文章分页",
        minWidth: 200,
        minHeight: 50,
        onShow: function () {
            var element = this.getParentEditor().getSelection().getSelectedElement();
            this.setupContent(element);
        },
        onOk: function () {
            editor = this.getParentEditor();
            element = CKEDITOR.dom.element.createFromHtml('<strong class="anyclass">[page:' + CMSPageCount + ']</strong>');
            this.commitContent(element);
            //element.innerHTML = '<div>[page:1]</div>';
            editor.insertElement(element);
        },
        onCancel: function () {
            if (CMSPageCount > 1)
                CMSPageCount--;
        },
        contents: [
			{
			    id: 'tab1',
			    label: '',
			    title: '',
			    expand: true,
			    padding: 0,
			    elements:
				[
					{
					    id: '_CMSPagerDesign',
					    type: 'text',
					    style: 'width:150px',
					    label: '请输入文章分页标识',
					    'default': '1',
					    accessKey: 'N',
					    setup: function (element) {
					        this.setValue(CMSPageCount);
					        CMSPageCount++;
					    },
					    commit: function (element) {
					        if (this.getValue()) {
					            element.$.innerText = '[page:' + this.getValue() + ']';
					        }
					    }
					}
				]
			}
		],
        buttons: [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton]
    };
});
